home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / ptf12.zip / PTFSPEC.SRC < prev    next >
Text File  |  1990-05-12  |  82KB  |  2,715 lines

  1. --::::::::::
  2. --clp.a
  3. --::::::::::
  4. --X1804: CSC 
  5. -- **********************************************
  6. -- *                                            *
  7. -- * COMMAND_LINE_PROCESSOR                     * SPEC
  8. -- *                                            *
  9. -- **********************************************
  10. package COMMAND_LINE_PROCESSOR is
  11. --| Purpose
  12. --|   COMMAND_LINE_PROCESSOR is an abstract state machine
  13. --| that allows the user to access a command line, which
  14. --| may contain file references which are include files,
  15. --| as a simple list of file names which can be accessed
  16. --| via an interator and a Get function.  The command line
  17. --| syntax is:
  18. --|
  19. --|      command input_file input_file ... output_file
  20. --| or:
  21. --|      command input_file input_file ... input_file
  22. --|
  23. --| where any "input_file" may be prefixed by an "@"
  24. --| to make it an include file.
  25. --|
  26. --| Initialization Exceptions (none)
  27. --| Notes
  28. --|   This package depends on package CLI from the ASR
  29. --|   File: PD2:<ADA.COMPONENTS>CLI2.SRC
  30. --| Modifications
  31. --|   2/19/90  Rick Conn  Initial Design and Code
  32. --|   5/7/90   Rick Conn  Cleanup and removal of FILE_LISTER2
  33.  
  34.     INCLUDE_FILE_PREFIX  : constant CHARACTER := '@';
  35.     -- This character is the prefix flag for an include
  36.     -- file name.
  37.  
  38.     MAX_FILE_NAME_LENGTH : constant           := 200;
  39.     -- Maximum length of a file name (change this
  40.     -- to match the target operating system)
  41.  
  42.     type COMMAND_LINE_LAYOUT is (ALL_INPUT_FILES,
  43.                                  ONE_OUTPUT_FILE);
  44.     -- The command line either contains only input
  45.     -- files or a group of input files and one
  46.     -- output file.  COMMAND_LINE_LAYOUT distinguishes
  47.     -- command lines of the form
  48.     --    PROGRAM_NAME infile infile ...
  49.     -- from command lines of the form
  50.     --    PROGRAM_NAME infile infile ... outfile
  51.  
  52.     --X1804: CSU
  53.     -- ..............................................
  54.     -- .                                            .
  55.     -- . INITIALIZE                                 . SPEC
  56.     -- .                                            .
  57.     -- ..............................................
  58.     procedure INITIALIZE (PROGRAM_NAME : in STRING;
  59.                           COMMAND_KIND : in COMMAND_LINE_LAYOUT
  60.                                          := ONE_OUTPUT_FILE);
  61.     --| Purpose
  62.     --| Initialize the package, specifying a program
  63.     --| name which may be used by the Command Line
  64.     --| Interface.
  65.  
  66.     --X1804: CSU
  67.     -- ..............................................
  68.     -- .                                            .
  69.     -- . RESET                                      . SPEC
  70.     -- .                                            .
  71.     -- ..............................................
  72.     procedure RESET;
  73.     --| Purpose
  74.     --| Reset the iterator so the next call to FILE_NAME
  75.     --| returns the first file in the list.  If this
  76.     --| package is iterated over only once, RESET need
  77.     --| not be called.
  78.  
  79.     --X1804: CSU
  80.     -- ..............................................
  81.     -- .                                            .
  82.     -- . IS_END                                     . SPEC
  83.     -- .                                            .
  84.     -- ..............................................
  85.     function IS_END return BOOLEAN;
  86.     --| Purpose
  87.     --| Indicate if any more file names are available.
  88.     --| Return TRUE if not.
  89.  
  90.     --X1804: CSU
  91.     -- ..............................................
  92.     -- .                                            .
  93.     -- . FILE_NAME                                  . SPEC
  94.     -- .                                            .
  95.     -- ..............................................
  96.     function FILE_NAME return STRING;
  97.     --| Purpose
  98.     --| Return the name of the next file and increment
  99.     --| the iterator.
  100.  
  101.     --X1804: CSU
  102.     -- ..............................................
  103.     -- .                                            .
  104.     -- . OUTPUT_FILE_NAME                           . SPEC
  105.     -- .                                            .
  106.     -- ..............................................
  107.     function OUTPUT_FILE_NAME return STRING;
  108.     --| Purpose
  109.     --| Return the name of the output file.  If INITIALIZE
  110.     --| was called with ALL_INPUT_FILES, return a null string.
  111.  
  112.     --X1804: CSU
  113.     -- ..............................................
  114.     -- .                                            .
  115.     -- . FILE_NAME_COUNT                            . SPEC
  116.     -- .                                            .
  117.     -- ..............................................
  118.     function FILE_NAME_COUNT return NATURAL;
  119.     --| Purpose
  120.     --| Return the number of file names in command line.
  121.     --| This is like CLI.ARGC-1, and is a token count.  It
  122.     --| returns the same value regardless if ALL_INPUT_FILES or
  123.     --| ONE_OUTPUT_FILE was used.
  124.  
  125.     ALLOCATION_PROBLEM     : exception;  -- raised by INITIALIZE
  126.     END_OF_FILE_LIST       : exception;  -- raised by FILE_NAME
  127.     INIT_ERROR             : exception;  -- raised when INITIALIZE
  128.                                          -- not called
  129.     INCLUDE_FILE_NOT_FOUND : exception;  -- raised by INITIALIZE
  130.     UNEXPECTED_ERROR       : exception;
  131.  
  132. end COMMAND_LINE_PROCESSOR;
  133. --::::::::::
  134. --dyn.a
  135. --::::::::::
  136. package DYN is 
  137. -- This package is derived from DSTR3.SRC in the Ada Software Repository
  138. -- DSTR3.SRC was written by R.G. Cleaveland.  The derivation, done by
  139. -- Richard Conn, was done to remove those general-purpose features of the
  140. -- package not needed for the PTF project.
  141. ------------------------------------------------------------------------------
  142. --  This is a package of several string manipulation functions based on     --
  143. -- a built-in dynamic STRING type DYN_STRING.  It is an adaptation and      --
  144. -- extension of the package proposed by Sylvan Rubin of Ford Aerospace and  --
  145. -- Communications Corporation in the Nov/Dec 1984 issue of the Journal of   --
  146. -- Pascal, Ada and Modula-2.  Some new functions have been added, and much  --
  147. -- of the body code has been rewritten.                                     --
  148. ------------------------------------------------------------------------------
  149. -- R.G. Cleaveland 07 December 1984:                                        --
  150. --  Implementation initially with the Telesoft Ada version 1.3.             --
  151. -- 06 Feb 85: CHAR changed to add the optional parameter POSIT.             --
  152. -- 06 Feb 85: procedure SUBSTITUTE added.                                   --
  153. -- 05 Apr 85: procedures UPPERCASE and CHECKBYTE added.                     --
  154. -- 04 Feb 86: style and formatting changes made, some comments fixed.       --
  155. -- Ported to VERDIX VADS (VAX Ultrix version 5.1).                          --
  156. -- 10 Feb 86: Several bugs fixed - SIZE constrained, exception for '&'      --
  157. -- generating too long a string added, error in integer conversion fixed.   --
  158. -- Functions EQUALS, ">", "<=" and ">=" added.  Subtype DS_POS incorporated.--
  159. ------------------------------------------------------------------------------
  160.  
  161.   MAX_D_STRING_LENGTH : constant POSITIVE := 100; 
  162.     -- This is the maximum LENGTH of a dynamic string implemented with this
  163.     -- package.  This value is "arbitrary" in that any reasonable number
  164.     -- equal to or less than the maximum STRING LENGTH permitted by the
  165.     -- compiler is acceptable.  The specific value above was chosen as a
  166.     -- compromise between programmer convenience and memory space requirements.
  167.  
  168.  
  169.  
  170.   subtype DS_POS is INTEGER range 0..MAX_D_STRING_LENGTH;
  171.   
  172.   type DYN_STRING is private;
  173.  
  174.   STRING_TOO_SHORT: exception;
  175.  
  176.   
  177.   
  178.   function D_STRING(CHAR: CHARACTER)  return DYN_STRING;
  179.           -- Creates a one-byte dynamic string of contents CHAR.
  180.  
  181.   function D_STRING(STR : STRING   )  return DYN_STRING;
  182.           -- Creates a dynamic string of contents STR.
  183.  
  184.   function CHAR(DSTR  : DYN_STRING;
  185.                 POSIT : POSITIVE := 1) return CHARACTER;
  186.   
  187.   function STR (DSTR: DYN_STRING) return STRING;
  188.   
  189.   function LENGTH(DSTR: DYN_STRING)     return NATURAL;
  190.     -- returns the LENGTH of the dynamic string.
  191.  
  192.   procedure CLEAR(DSTR: in out DYN_STRING);
  193.                   -- makes DSTR a null string.
  194.  
  195. private
  196.   type DYN_STRING is
  197.     record
  198.       SIZE: INTEGER range 0..MAX_D_STRING_LENGTH;
  199.       DATA: STRING(1..MAX_D_STRING_LENGTH);
  200.     end record;
  201. end DYN;
  202.  
  203.  
  204. package body DYN is
  205.            
  206.   procedure CLEAR(DSTR: in out DYN_STRING) is
  207.     
  208.     begin
  209.       DSTR.SIZE := 0;
  210.     end CLEAR;
  211.  
  212.   function D_STRING(CHAR: CHARACTER)  return DYN_STRING is
  213.           
  214.       DS : DYN_STRING;
  215.     
  216.     begin
  217.       DS.SIZE     := 1;
  218.       DS.DATA(1)  := CHAR;
  219.       return DS;
  220.     end D_STRING;
  221.   
  222.   function D_STRING(STR : STRING   )  return DYN_STRING is
  223.           
  224.       DS : DYN_STRING;
  225.     
  226.     begin
  227.       DS.SIZE                   := STR'LENGTH;
  228.       DS.DATA(1..DS.SIZE)       := STR;
  229.       return DS;
  230.     end D_STRING;
  231.   
  232.   function CHAR(DSTR  : DYN_STRING;
  233.                 POSIT : POSITIVE := 1) return CHARACTER is
  234.     
  235.     begin
  236.       if POSIT > DSTR.SIZE then 
  237.         raise STRING_TOO_SHORT;
  238.       else 
  239.         return DSTR.DATA(POSIT);
  240.       end if;
  241.     end CHAR;
  242.   
  243.   function STR (DSTR: DYN_STRING) return STRING is
  244.     
  245.     begin
  246.       return DSTR.DATA(1..DSTR.SIZE);
  247.     end STR;
  248.   
  249.   function LENGTH(DSTR: DYN_STRING) return NATURAL is
  250.     
  251.     begin
  252.       return DSTR.SIZE;
  253.     end LENGTH;
  254.   
  255.     begin --(DYN)
  256.       null;
  257.     exception
  258.       when others => 
  259.         raise;
  260.  
  261.     end DYN;
  262. --::::::::::
  263. --sort.a
  264. --::::::::::
  265.  
  266.  
  267. -------- SIMTEL20 Ada Software Repository Prologue ------------
  268. --                                                           -*
  269. -- Unit name    : generic procedure SORT
  270. -- Version      : 1.0
  271. -- Author       : John A. Anderson
  272. --              : TEXAS INSTRUMENTS MS 8006
  273. --              : P.O. BOX 801
  274. --              : MCKINNEY, TEXAS   75069
  275. --              :
  276. -- DDN Address  : ANDERSON%TI-EG at CSNET-RELAY
  277. -- Copyright    : (c) 1984, 1985 John Anderson
  278. -- Date created :  December 19, 1984
  279. -- Release Date : January 10, 1985
  280. -- Last update  :  ANDERSON Wed Dec 19, 1984
  281. -- Machine/System Compiled/Run on : DG MV 10000, Ada Development 
  282. --                                :   Environment
  283. --                                                           -*
  284. ---------------------------------------------------------------
  285. --                                                           -*
  286. -- Abstract     :  This generic procedure uses the QuickSort
  287. ----------------:  algorithm to sort an array of any base type
  288. ----------------:  with any discrete index type.
  289. ----------------:   Associated Files:
  290. ----------------:       SORT.ADA      -- generic Quick Sort
  291. ----------------:       OTHERTEST.ADA -- test program (for any
  292. ----------------:          generic sort with the same visible section
  293. ----------------:
  294. ------------------ Revision history ---------------------------
  295. --
  296. -- DATE         AUTHOR                  HISTORY
  297. -- 10 Jan 85      John Anderson        Initial Release
  298. --
  299. -------------------END-PROLOGUE--------------------------------
  300. generic
  301.     type ITEM is private;
  302.  
  303.     type INDEX is (<>);
  304.  
  305.     type ROW is array (INDEX range <>) of ITEM;
  306.  
  307.     with function "<" (X, Y : ITEM) return BOOLEAN is <>;
  308.  
  309. procedure SORT (A : in out ROW);
  310.  
  311.  
  312. with TEXT_IO;
  313. procedure SORT (A : in out ROW) is
  314.  
  315.     procedure QSORT (L, R : INDEX) is
  316.  
  317.         I, J : INDEX;
  318.         X    : ITEM;
  319.  
  320.         procedure EXCHANGE (A, B : in out ITEM) is
  321.             TEMP : ITEM;
  322.         begin
  323.             TEMP := A;
  324.             A := B;
  325.             B := TEMP;
  326.         end EXCHANGE;
  327.  
  328.     begin
  329.  
  330.         I := L;
  331.         J := R;
  332.  
  333.         X := A (INDEX'VAL ((INDEX'POS (L) + INDEX'POS (R)) / 2));
  334.  
  335.         MAIN:
  336.         loop
  337.  
  338.             while A (I) < X loop
  339.                 I := INDEX'SUCC (I);
  340.             end loop;
  341.  
  342.             while X < A (J) loop
  343.                 J := INDEX'PRED (J);
  344.             end loop;
  345.  
  346.             if I <= J then
  347.                 EXCHANGE (A (I), A (J));
  348.  
  349.                 begin
  350.                     I := INDEX'SUCC (I);
  351.                     J := INDEX'PRED (J);
  352.                 exception
  353.                     when CONSTRAINT_ERROR =>
  354.                         null; -- necessary to avoid exception raising
  355.                 end;
  356.  
  357.             end if;
  358.  
  359.             exit when I > J;
  360.  
  361.         end loop MAIN;
  362.  
  363.         if L < J then
  364.             QSORT (L, J);
  365.         end if;
  366.  
  367.         if I < R then
  368.             QSORT (I, R);
  369.         end if;
  370.  
  371.     end QSORT;
  372.  
  373. begin
  374.  
  375.     QSORT (A'FIRST, A'LAST);
  376.  
  377. exception
  378.     when others =>
  379.         TEXT_IO.PUT_LINE ("Exception raised in Generic Sort");
  380.         raise;
  381. end SORT;
  382. --::::::::::
  383. --cot.a
  384. --::::::::::
  385. -- **********************************
  386. -- *                                *
  387. -- *  Console                       *  SPEC
  388. -- *                                *
  389. -- **********************************
  390. package Console is
  391.  
  392. --| Purpose
  393. --| Console implements an abstract state machine of a console terminal.
  394. --| Console offers an abstraction that can be made more efficient
  395. --| by not using Text_IO (and having its associated overhead imposed)
  396. --| if possible.
  397. --|
  398. --| Initialization Exceptions (none)
  399. --| Notes (none)
  400. --|
  401. --| Modifications
  402. --| 08/16/89  Rick Conn    Initial Version
  403.  
  404.   -- ..................................
  405.   -- .                                .
  406.   -- .  Put                           .  SPEC
  407.   -- .                                .
  408.   -- ..................................
  409.   procedure Put
  410.     ( Item           : in CHARACTER );
  411.   procedure Put
  412.     ( Item           : in STRING );
  413.  
  414.   --| Purpose
  415.   --| Put writes an Item to the console.
  416.   --|
  417.   --| Exceptions (none)
  418.   --| Notes (none)
  419.  
  420.   -- ..................................
  421.   -- .                                .
  422.   -- .  Put_Line                      .  SPEC
  423.   -- .                                .
  424.   -- ..................................
  425.   procedure Put_Line
  426.     ( Item           : in STRING );
  427.  
  428.   --| Purpose
  429.   --| Put_Line writes an Item to the console.  The Item is followed
  430.   --| by a New_Line;
  431.   --|
  432.   --| Exceptions (none)
  433.   --| Notes (none)
  434.  
  435.   -- ..................................
  436.   -- .                                .
  437.   -- .  New_Line                      .  SPEC
  438.   -- .                                .
  439.   -- ..................................
  440.   procedure New_Line;
  441.  
  442.   --| Purpose
  443.   --| New_Line writes an end-of-line sequence to the console.
  444.   --|
  445.   --| Exceptions (none)
  446.   --| Notes (none)
  447.  
  448.   -- ..................................
  449.   -- .                                .
  450.   -- .  Get_Line                      .  SPEC
  451.   -- .                                .
  452.   -- ..................................
  453.   procedure Get_Line
  454.     ( Item           : out STRING;
  455.       Last           : out NATURAL );
  456.  
  457.   --| Purpose
  458.   --| Get_Line reads a line from the console.
  459.   --|
  460.   --| Exceptions (none)
  461.   --| Notes (none)
  462.  
  463. end Console;
  464. --::::::::::
  465. --in.a
  466. --::::::::::
  467. -- **********************************
  468. -- *                                *
  469. -- *  Input_File                    *  SPEC
  470. -- *                                *
  471. -- **********************************
  472. package Input_File is
  473.  
  474. --| Purpose
  475. --| Input_File implements an abstract data type of an input file.
  476. --| Input_File offers an abstraction that can be made more efficient
  477. --| by not using Text_IO (and having its associated overhead imposed)
  478. --| if possible,
  479. --|
  480. --| Initialization Exceptions (none)
  481. --| Notes (none)
  482. --|
  483. --| Modifications
  484. --| 08/16/89  Rick Conn    Initial Version
  485.  
  486.   type FILE_TYPE is
  487.     private;
  488.  
  489.   Cannot_Open_Input_File
  490.     : exception;
  491.  
  492.   Read_Error
  493.     : exception;
  494.  
  495.   -- ..................................
  496.   -- .                                .
  497.   -- .  Open                          .  SPEC
  498.   -- .                                .
  499.   -- ..................................
  500.  
  501.   procedure Open
  502.     ( Id             : in out FILE_TYPE;
  503.       File_Name      : in STRING );
  504.  
  505.   --| Purpose
  506.   --| Open an existing FILE_TYPE object.
  507.   --|
  508.   --| Exceptions
  509.   --|   Cannot_Open_Input_File
  510.   --|
  511.   --| Notes (none)
  512.  
  513.   -- ..................................
  514.   -- .                                .
  515.   -- .  Get_Line                      .  SPEC
  516.   -- .                                .
  517.   -- ..................................
  518.   procedure Get_Line
  519.     ( Id             : in out FILE_TYPE;
  520.       Item           : out STRING;
  521.       Last           : out NATURAL );
  522.  
  523.   --| Purpose
  524.   --| Get_Line reads an Item to the FILE_TYPE object.
  525.   --|
  526.   --| Exceptions
  527.   --|   Read_Error
  528.   --|
  529.   --| Notes (none)
  530.  
  531.   -- ..................................
  532.   -- .                                .
  533.   -- .  End_Of_File                   .  SPEC
  534.   -- .                                .
  535.   -- ..................................
  536.   function End_Of_File
  537.     ( Id             : in FILE_TYPE )
  538.       return BOOLEAN;
  539.  
  540.   --| Purpose
  541.   --| End_Of_File returns TRUE if the FILE_TYPE object is empty or
  542.   --| no more data is in it.
  543.   --|
  544.   --| Exceptions
  545.   --|   Read_Error
  546.   --|
  547.   --| Notes (none)
  548.  
  549.   -- ..................................
  550.   -- .                                .
  551.   -- .  Close                         .  SPEC
  552.   -- .                                .
  553.   -- ..................................
  554.   procedure Close
  555.     ( Id             : in out FILE_TYPE );
  556.  
  557.   --| Purpose
  558.   --| Close closes input from the FILE_TYPE object.
  559.   --|
  560.   --| Exceptions (none)
  561.   --| Notes (none)
  562.  
  563. private -- Input_File
  564.   type FILE_OBJECT;
  565.   type FILE_TYPE is
  566.     access FILE_OBJECT;
  567.  
  568. end Input_File;
  569. --::::::::::
  570. --out.a
  571. --::::::::::
  572. -- **********************************
  573. -- *                                *
  574. -- *  Output_File                   *  SPEC
  575. -- *                                *
  576. -- **********************************
  577. package Output_File is
  578.  
  579. --| Purpose
  580. --| Output_File implements an abstract data type of an output file.
  581. --| Output_File offers an abstraction that can be made more efficient
  582. --| by not using Text_IO (and having its associated overhead imposed)
  583. --| if possible and also offers the ability to suppress the output,
  584. --| which may be desired if a caller is skipping over pages and just
  585. --| wants to output to a null device during this process.
  586. --|
  587. --| Initialization Exceptions (none)
  588. --| Notes (none)
  589. --|
  590. --| Modifications
  591. --| 08/16/89  Rick Conn    Initial Version
  592.  
  593.   type FILE_TYPE is
  594.     private;
  595.  
  596.   Cannot_Create_Output_File
  597.     : exception;
  598.  
  599.   Write_Error
  600.     : exception;
  601.  
  602.   -- ..................................
  603.   -- .                                .
  604.   -- .  Already_Exists                .  SPEC
  605.   -- .                                .
  606.   -- ..................................
  607.   function Already_Exists
  608.     ( File_Name      : in STRING )
  609.     return BOOLEAN;
  610.  
  611.   --| Purpose
  612.   --| Determine if the FILE_TYPE object already exists.
  613.   --|
  614.   --| Exceptions (none)
  615.   --| Notes (none)
  616.  
  617.   -- ..................................
  618.   -- .                                .
  619.   -- .  Delete                        .  SPEC
  620.   -- .                                .
  621.   -- ..................................
  622.   function Delete
  623.     ( File_Name      : in STRING )
  624.     return BOOLEAN;
  625.  
  626.   --| Purpose
  627.   --| Delete the FILE_TYPE object.  Return TRUE if successful.
  628.   --|
  629.   --| Exceptions (none)
  630.   --| Notes (none)
  631.  
  632.   -- ..................................
  633.   -- .                                .
  634.   -- .  Create                        .  SPEC
  635.   -- .                                .
  636.   -- ..................................
  637.   procedure Create
  638.     ( Id             : in out FILE_TYPE;
  639.       File_Name      : in STRING );
  640.  
  641.   --| Purpose
  642.   --| Create creates a new FILE_TYPE object.
  643.   --|
  644.   --| Exceptions
  645.   --|   Cannot_Create_Output_File
  646.   --|
  647.   --| Notes (none)
  648.  
  649.   -- ..................................
  650.   -- .                                .
  651.   -- .  Put                           .  SPEC
  652.   -- .                                .
  653.   -- ..................................
  654.   procedure Put
  655.     ( Id             : in out FILE_TYPE;
  656.       Item           : in CHARACTER );
  657.   procedure Put
  658.     ( Id             : in out FILE_TYPE;
  659.       Item           : in STRING );
  660.  
  661.   --| Purpose
  662.   --| Put writes an Item to the FILE_TYPE object.
  663.   --|
  664.   --| Exceptions
  665.   --|   Write_Error
  666.   --|
  667.   --| Notes (none)
  668.  
  669.   -- ..................................
  670.   -- .                                .
  671.   -- .  Put_Line                      .  SPEC
  672.   -- .                                .
  673.   -- ..................................
  674.   procedure Put_Line
  675.     ( Id             : in out FILE_TYPE;
  676.       Item           : in STRING );
  677.  
  678.   --| Purpose
  679.   --| Put_Line writes an Item to the FILE_TYPE object.  The Item is followed
  680.   --| by a New_Line;
  681.   --|
  682.   --| Exceptions
  683.   --|   Write_Error
  684.   --|
  685.   --| Notes (none)
  686.  
  687.   -- ..................................
  688.   -- .                                .
  689.   -- .  New_Line                      .  SPEC
  690.   -- .                                .
  691.   -- ..................................
  692.   procedure New_Line
  693.     ( Id             : in out FILE_TYPE );
  694.  
  695.   --| Purpose
  696.   --| New_Line writes an end-of-line sequence to the FILE_TYPE object.
  697.   --|
  698.   --| Exceptions
  699.   --|   Write_Error
  700.   --|
  701.   --| Notes (none)
  702.  
  703.   -- ..................................
  704.   -- .                                .
  705.   -- .  New_Page                      .  SPEC
  706.   -- .                                .
  707.   -- ..................................
  708.   procedure New_Page
  709.     ( Id             : in out FILE_TYPE );
  710.  
  711.   --| Purpose
  712.   --| New_Page writes an end-of-page sequence to the FILE_TYPE object.
  713.   --|
  714.   --| Exceptions
  715.   --|   Write_Error
  716.   --|
  717.   --| Notes (none)
  718.  
  719.   -- ..................................
  720.   -- .                                .
  721.   -- .  Enable_Output                 .  SPEC
  722.   -- .  Disable_Output                .
  723.   -- .                                .
  724.   -- ..................................
  725.   procedure Enable_Output
  726.     ( Id             : in out FILE_TYPE );
  727.   procedure Disable_Output
  728.     ( Id             : in out FILE_TYPE );
  729.  
  730.   --| Purpose
  731.   --| Enable_Output and Disable_Output enable and disable the output of
  732.   --| Items and new lines to the FILE_TYPE object.  When created, output
  733.   --| to a FILE_TYPE object is enabled.
  734.   --|
  735.   --| Exceptions (none)
  736.   --| Notes (none)
  737.  
  738.   -- ..................................
  739.   -- .                                .
  740.   -- .  Close                         .  SPEC
  741.   -- .                                .
  742.   -- ..................................
  743.   procedure Close
  744.     ( Id             : in out FILE_TYPE );
  745.  
  746.   --| Purpose
  747.   --| Close closes output to the FILE_TYPE object.
  748.   --|
  749.   --| Exceptions (none)
  750.   --| Notes (none)
  751.  
  752. private -- Output_File
  753.   type FILE_OBJECT;
  754.   type FILE_TYPE is
  755.     access FILE_OBJECT;
  756.  
  757. end Output_File;
  758. --::::::::::
  759. --cmd_sym.a
  760. --::::::::::
  761. -- **********************************
  762. -- *                                *
  763. -- *  Command_Symbols               *  SPEC & BODY
  764. -- *                                *
  765. -- **********************************
  766. package Command_Symbols is
  767.  
  768. --| Purpose
  769. --| Command_Symbols contains the command name table used by the body of
  770. --| package Command.  It also contains the error messages issued by
  771. --| routines within the package.
  772. --|
  773. --| Initialization Exceptions (none)
  774. --| Notes (none)
  775. --|
  776. --| Modifications
  777. --| 08/16/89  Rick Conn    Initial Version
  778. --| 02/26/90  Rick Conn    Added .du, .eu commands
  779.  
  780.   Command_Text_Length
  781.     : constant
  782.       := 12;
  783.  
  784.   Ltw_Length
  785.     : constant
  786.       := 20;
  787.  
  788.   type COMMAND_ID is
  789.     ( UNKNOWN, AUTO_PARAGRAPH, BOLD, BREAK, CENTER, COMMENT, CONSOLE_MESSAGE,
  790.         CONTENTS_SELECT, DISABLE_BOLDING, ENABLE_BOLDING, ENTER_CONTENTS,
  791.         ENVIRONMENT_POP, ENVIRONMENT_PUSH, FILL, FOOTER, FOOTER_EVEN,
  792.         FOOTER_ODD, HEADER, HEADER_EVEN, HEADER_ODD, INCLUDE, INDEX_ENTRY,
  793.         INDEX_LENGTH, JUSTIFY, LEFT_INDENT, LEFT_MARGIN,
  794.         LEX, LINE_SPACING, NL_BOTTOM, NL_FOOTER, NL_HEADER, NL_TOP,
  795.         NO_AUTO_PARAGRAPH, NO_FILL, NO_JUSTIFY, NO_PAGING, NUMBER_REGISTER,
  796.         OFFSET, PAGE, PAGE_NUMBER_FORMAT, PAGE_SIZE, PAGING, PRINT_CONTENTS,
  797.         RIGHT_INDENT, RIGHT_MARGIN, SET_CCHAR, SET_ECHAR, SET_FCHAR, SKIP,
  798.         SPACE_TO, START_MACRO, STOP_MACRO, TEMPORARY_INDENT, TEST_PAGE,
  799.         UNDERLINE, UNDERLINE_MODE, DISABLE_UNDERLINING, ENABLE_UNDERLINING,
  800.         VARIABLE_GET, VARIABLE_SET, WRITE );
  801.  
  802.   subtype COMMAND_TEXT is
  803.     STRING (1 .. Command_Text_Length);
  804.  
  805.   type COMMAND_DEFINITION is
  806.     record
  807.       Id             : COMMAND_ID;
  808.       Name           : COMMAND_TEXT;
  809.     end record;
  810.  
  811.   type COMMAND_LIST is
  812.     array (NATURAL range <>)
  813.       of COMMAND_DEFINITION;
  814.  
  815.   pragma Format_Off;
  816.  
  817.   Cl
  818.     : COMMAND_LIST(1..120)
  819.       := (
  820.         (AUTO_PARAGRAPH,      "ap          "),
  821.         (BOLD,                "bd          "),
  822.         (BOLD,                "bold        "),
  823.         (BREAK,               "br          "),
  824.         (BREAK,               "break       "),
  825.         (CENTER,              "ce          "),
  826.         (CENTER,              "center      "),
  827.         (COMMENT,             "#           "),
  828.         (COMMENT,             ".           "),
  829.         (COMMENT,             "!           "),
  830.         (COMMENT,             "comment     "),
  831.         (CONSOLE_MESSAGE,     "con         "),
  832.         (CONSOLE_MESSAGE,     "console     "),
  833.         (CONSOLE_MESSAGE,     "msg         "),
  834.         (CONTENTS_SELECT,     "contsel     "),
  835.         (DISABLE_BOLDING,     "db          "),
  836.         (DISABLE_BOLDING,     "dbo         "),
  837.         (ENABLE_BOLDING,      "eb          "),
  838.         (ENABLE_BOLDING,      "ebo         "),
  839.         (ENTER_CONTENTS,      "cl          "),
  840.         (ENTER_CONTENTS,      "contline    "),
  841.         (ENVIRONMENT_POP,     "restore     "),
  842.         (ENVIRONMENT_POP,     "rs          "),
  843.         (ENVIRONMENT_PUSH,    "save        "),
  844.         (ENVIRONMENT_PUSH,    "sv          "),
  845.         (FILL,                "f           "),
  846.         (FILL,                "fi          "),
  847.         (FILL,                "fill        "),
  848.         (FOOTER,              "fo          "),
  849.         (FOOTER,              "footer      "),
  850.         (FOOTER_EVEN,         "ef          "),
  851.         (FOOTER_ODD,          "of          "),
  852.         (HEADER,              "he          "),
  853.         (HEADER,              "header      "),
  854.         (HEADER_EVEN,         "eh          "),
  855.         (HEADER_ODD,          "oh          "),
  856.         (INCLUDE,             "include     "),
  857.         (INCLUDE,             "so          "),
  858.         (INCLUDE,             "source      "),
  859.         (INCLUDE,             "require     "),
  860.         (INDEX_ENTRY,         "index       "),
  861.         (INDEX_ENTRY,         "idx         "),
  862.         (INDEX_LENGTH,        "indexlength "),
  863.         (JUSTIFY,             "j           "),
  864.         (JUSTIFY,             "ju          "),
  865.         (JUSTIFY,             "justify     "),
  866.         (LEFT_INDENT,         "in          "),
  867.         (LEFT_INDENT,         "indent      "),
  868.         (LEFT_INDENT,         "li          "),
  869.         (LEFT_INDENT,         "leftindent  "),
  870.         (LEFT_MARGIN,         "leftmargin  "),
  871.         (LEFT_MARGIN,         "lm          "),
  872.         (LEX,                 "lex         "),
  873.         (LEX,                 "lx          "),
  874.         (LINE_SPACING,        "ls          "),
  875.         (LINE_SPACING,        "spacing     "),
  876.         (LINE_SPACING,        "spc         "),
  877.         (NL_BOTTOM,           "nlbottom    "),
  878.         (NL_FOOTER,           "nlfooter    "),
  879.         (NL_HEADER,           "nlheader    "),
  880.         (NL_TOP,              "nltop       "),
  881.         (NO_AUTO_PARAGRAPH,   "na          "),
  882.         (NO_AUTO_PARAGRAPH,   "nap         "),
  883.         (NO_FILL,             "nf          "),
  884.         (NO_FILL,             "nofill      "),
  885.         (NO_JUSTIFY,          "nj          "),
  886.         (NO_JUSTIFY,          "nojustify   "),
  887.         (NO_PAGING,           "nopaging    "),
  888.         (NO_PAGING,           "np          "),
  889.         (NUMBER_REGISTER,     "nr          "),
  890.         (OFFSET,              "offset      "),
  891.         (OFFSET,              "po          "),
  892.         (PAGE,                "bp          "),
  893.         (PAGE,                "page        "),
  894.         (PAGE,                "pg          "),
  895.         (PAGE_NUMBER_FORMAT,  "pagenumber  "),
  896.         (PAGE_NUMBER_FORMAT,  "pn          "),
  897.         (PAGE_SIZE,           "pagesize    "),
  898.         (PAGE_SIZE,           "pl          "),
  899.         (PAGE_SIZE,           "ps          "),
  900.         (PAGING,              "pa          "),
  901.         (PAGING,              "paging      "),
  902.         (PRINT_CONTENTS,      "pc          "),
  903.         (PRINT_CONTENTS,      "printcont   "),
  904.         (RIGHT_INDENT,        "ri          "),
  905.         (RIGHT_INDENT,        "rightindent "),
  906.         (RIGHT_MARGIN,        "rightmargin "),
  907.         (RIGHT_MARGIN,        "rm          "),
  908.         (SET_CCHAR,           "cc          "),
  909.         (SET_CCHAR,           "cchar       "),
  910.         (SET_ECHAR,           "ec          "),
  911.         (SET_ECHAR,           "echar       "),
  912.         (SET_FCHAR,           "fc          "),
  913.         (SET_FCHAR,           "fchar       "),
  914.         (SKIP,                "s           "),
  915.         (SKIP,                "skip        "),
  916.         (SKIP,                "sp          "),
  917.         (SPACE_TO,            "spaceto     "),
  918.         (SPACE_TO,            "st          "),
  919.         (START_MACRO,         "de          "),
  920.         (START_MACRO,         "define      "),
  921.         (STOP_MACRO,          "en          "),
  922.         (TEMPORARY_INDENT,    "i           "),
  923.         (TEMPORARY_INDENT,    "left        "),
  924.         (TEMPORARY_INDENT,    "ti          "),
  925.         (TEST_PAGE,           "ne          "),
  926.         (TEST_PAGE,           "need        "),
  927.         (TEST_PAGE,           "testpage    "),
  928.         (TEST_PAGE,           "tp          "),
  929.         (UNDERLINE,           "ul          "),
  930.         (UNDERLINE,           "underline   "),
  931.         (UNDERLINE_MODE,      "ulmode      "),
  932.         (DISABLE_UNDERLINING, "du          "),
  933.         (ENABLE_UNDERLINING,  "eu          "),
  934.         (VARIABLE_GET,        "get         "),
  935.         (VARIABLE_GET,        "vg          "),
  936.         (VARIABLE_SET,        "set         "),
  937.         (VARIABLE_SET,        "vs          "),
  938.         (WRITE,               "wr          "),
  939.         (WRITE,               "write       ")
  940.       );
  941.  
  942.   pragma Format_On;
  943.  
  944.   Error_Create
  945.     : constant STRING
  946.       := "4.1.A. Cannot create output file";
  947.  
  948.   Error_Delete_File
  949.     : constant STRING
  950.       := "4.1.B. Cannot delete old output file";
  951.  
  952.   Error_Expansion
  953.     : constant STRING
  954.       := "4.1.C. Not enough room to expand line";
  955.  
  956.   Error_Fatal
  957.     : constant STRING
  958.       := "4.1.D. Unexpected fatal error";
  959.  
  960.   Error_Hf_Lines
  961.     : constant STRING
  962.       := "4.1.E. Range error on number of header or footer lines";
  963.  
  964.   Error_Include
  965.     : constant STRING
  966.       := "4.1.F. Error in include file: ";
  967.  
  968.   Error_Indent
  969.     : constant STRING
  970.       := "4.1.G. Indentation would move to before page boundary";
  971.  
  972.   Error_Index_File_Create
  973.     : constant STRING
  974.       := "4.1.H. Cannot create index file";
  975.  
  976.   Error_Internal_Add_Index_Entry
  977.     : constant STRING
  978.       := "4.2.A. Internal error in Index.Add_Entry";
  979.  
  980.   Error_Internal_Add_Line
  981.     : constant STRING
  982.       := "4.2.B. Internal error in Contents.Add_Line";
  983.  
  984.   Error_Internal_Break_Line
  985.     : constant STRING
  986.       := "4.2.C. Internal error in FOF.Break_Line";
  987.  
  988.   Error_Internal_Break_Page_1
  989.     : constant STRING
  990.       := "4.2.D. Internal error in FOF.Break_Page (1st routine)";
  991.  
  992.   Error_Internal_Break_Page_2
  993.     : constant STRING
  994.       := "4.2.E. Internal error in FOF.Break_Page (2nd routine)";
  995.  
  996.   Error_Internal_Bottom
  997.     : constant STRING
  998.       := "4.2.F. Internal error in FOF.Output_Bottom_Of_Page";
  999.  
  1000.   Error_Internal_Hf_Line
  1001.     : constant STRING
  1002.       := "4.2.G. Internal error in FOF.Put_Header_Footer_Line";
  1003.  
  1004.   Error_Internal_Identify
  1005.     : constant STRING
  1006.       := "4.2.H. Internal error in Command.Identify";
  1007.  
  1008.   Error_Internal_Increment
  1009.     : constant STRING
  1010.       := "4.2.I. Internal error in Variable.Increment_Line_Number";
  1011.  
  1012.   Error_Internal_Macro_Define
  1013.     : constant STRING
  1014.       := "4.2.J. Internal error in Macro.Define_Parameters";
  1015.  
  1016.   Error_Internal_Macro_Write
  1017.     : constant STRING
  1018.       := "4.2.K. Internal error in Macro.Write";
  1019.  
  1020.   Error_Internal_Open
  1021.     : constant STRING
  1022.       := "4.2.L. Internal error in Word_Processor.Open_Output_File";
  1023.  
  1024.   Error_Internal_Pnum
  1025.     : constant STRING
  1026.       := "4.2.M. Internal error in FOF.Pnum_As_String";
  1027.  
  1028.   Error_Internal_Process
  1029.     : constant STRING
  1030.       := "4.2.N. Internal error in Command.Process";
  1031.  
  1032.   Error_Internal_Print
  1033.     : constant STRING
  1034.       := "4.2.O. Internal error in Contents.Print";
  1035.  
  1036.   Error_Internal_Put_Invisible
  1037.     : constant STRING
  1038.       := "4.2.P. Internal error in FOF.Put_Invisible_Word";
  1039.  
  1040.   Error_Internal_Put_Line
  1041.     : constant STRING
  1042.       := "4.2.Q. Internal error in FOF.Put_Line";
  1043.  
  1044.   Error_Internal_Put_What
  1045.     : constant STRING
  1046.       := "4.2.R. Internal error in FOF.Put_Word.Put_What";
  1047.  
  1048.   Error_Internal_Put_Word
  1049.     : constant STRING
  1050.       := "4.2.S. Internal error in FOF.Put_Word";
  1051.  
  1052.   Error_Internal_Set_Footer_Line
  1053.     : constant STRING
  1054.       := "4.2.T. Internal error in FOF.Set_Footer_Line";
  1055.  
  1056.   Error_Internal_Set_Header_Line
  1057.     : constant STRING
  1058.       := "4.2.U. Internal error in FOF.Set_Header_Line";
  1059.  
  1060.   Error_Internal_Set_Var
  1061.     : constant STRING
  1062.       := "4.2.V. Internal error in Variable.Set_Var";
  1063.  
  1064.   Error_Internal_Skip
  1065.     : constant STRING
  1066.       := "4.2.W. Internal error in FOF.Skip";
  1067.  
  1068.   Error_Internal_Top
  1069.     : constant STRING
  1070.       := "4.2.X. Internal error in FOF.Output_Top_Of_Page";
  1071.  
  1072.   Error_Internal_PTFIDX
  1073.     : constant STRING
  1074.       := "4.2.Y. Internal error in PTFIDX";
  1075.  
  1076.   Error_Invalid_Option
  1077.     : constant STRING
  1078.       := "4.1.I. Invalid option (not -db or -po#) in command line";
  1079.  
  1080.   Error_Lex
  1081.     : constant STRING
  1082.       := "4.1.J. No arguments given to .lex command";
  1083.  
  1084.   Error_Macro
  1085.     : constant STRING
  1086.       := "4.1.K Error in macro definition";
  1087.  
  1088.   Error_Macro_End
  1089.     : constant STRING
  1090.       := "4.1.L. Isolated macro end (.en) encountered";
  1091.  
  1092.   Error_Macro_Unknown_Command
  1093.     : constant STRING
  1094.       := "4.1.M. Unknown command/macro in macro definition";
  1095.  
  1096.   Error_Margin
  1097.     : constant STRING
  1098.       := "4.1.N. Left starting column greater than right";
  1099.  
  1100.   Error_Number
  1101.     : constant STRING
  1102.       := "4.1.O. Numeric conversion problem on ";
  1103.  
  1104.   Error_Number_Register
  1105.     : constant STRING
  1106.       := "4.1.P. Error in number register definition ";
  1107.  
  1108.   Error_Page_Number_Format
  1109.     : constant STRING
  1110.       := "4.1.Q. Invalid page number format requested";
  1111.  
  1112.   Error_Source_File
  1113.     : constant STRING
  1114.       := "4.1.R. Error in processing source file";
  1115.  
  1116.   Error_Spaceto
  1117.     : constant STRING
  1118.       := "4.1.S. Spaceto request is before current line";
  1119.  
  1120.   Error_Stack_Empty
  1121.     : constant STRING
  1122.       := "4.1.T. Restore requested of an empty stack";
  1123.  
  1124.   Error_Stack_Overflow
  1125.     : constant STRING
  1126.       := "4.1.U. Save resulted in an overflow of the stack -- save not done";
  1127.  
  1128.   Error_Unknown
  1129.     : constant STRING
  1130.       := "4.1.V. Unknown command";
  1131.  
  1132.   Error_User_Abort
  1133.     : constant STRING
  1134.       := "4.1.W. User Abort";
  1135.  
  1136.   Error_Write
  1137.     : constant STRING
  1138.       := "4.1.X. Write command buffer overflow";
  1139.  
  1140.   Error_Variable_Set
  1141.     : constant STRING
  1142.       := "4.1.Y. Error in variable get or set command";
  1143.  
  1144.   Error_Variable_Name
  1145.     : constant STRING
  1146.       := "4.1.Z. Variable not found";
  1147.  
  1148.   Warning_Contents_Line_Truncation
  1149.     : constant STRING
  1150.       := "4.3.A. Contents line too long - truncated";
  1151.  
  1152.   Warning_Contents_Number
  1153.     : constant STRING
  1154.       := "4.3.B. Invalid contents number - table 0 selected";
  1155.  
  1156.   Warning_Index_Line_Truncation
  1157.     : constant STRING
  1158.       := "4.3.C. Index line too long - truncated";
  1159.  
  1160.   Warning_Index_Width
  1161.     : constant STRING
  1162.       := "4.3.D. Index line too wide (index not in margins)";
  1163.  
  1164.   Warning_Table_Empty
  1165.     : constant STRING
  1166.       := "4.3.E. Current contents table is empty";
  1167.  
  1168. end Command_Symbols;
  1169. --::::::::::
  1170. --err.a
  1171. --::::::::::
  1172. -- **********************************
  1173. -- *                                *
  1174. -- *  Error_Log                     *  SPEC
  1175. -- *                                *
  1176. -- **********************************
  1177. package Error_Log is
  1178.  
  1179. --| Purpose
  1180. --| Error_Log is used to log errors to an output file or console.
  1181. --|
  1182. --| Initialization Exceptions (none)
  1183. --| Notes (none)
  1184. --|
  1185. --| Modifications
  1186. --| 08/16/89  Rick Conn    Initial Version
  1187.  
  1188.   -- ..................................
  1189.   -- .                                .
  1190.   -- .  Open                          .  SPEC
  1191.   -- .                                .
  1192.   -- ..................................
  1193.   procedure Open
  1194.     ( File_Name      : in STRING );
  1195.  
  1196.   --| Purpose
  1197.   --| Open the error log file.  If the File_Name is empty, error log
  1198.   --| goes to standard output.
  1199.   --|
  1200.   --| Exceptions (none)
  1201.   --| Notes (none)
  1202.  
  1203.   -- ..................................
  1204.   -- .                                .
  1205.   -- .  Write_Error                   .  SPEC
  1206.   -- .                                .
  1207.   -- ..................................
  1208.   procedure Write_Error
  1209.     ( Message        : in STRING );
  1210.  
  1211.   --| Purpose
  1212.   --| Write_Error makes an error message entry into the error log file.
  1213.   --|
  1214.   --| Exceptions (none)
  1215.   --| Notes (none)
  1216.  
  1217.   -- ..................................
  1218.   -- .                                .
  1219.   -- .  Write_Warning                 .  SPEC
  1220.   -- .                                .
  1221.   -- ..................................
  1222.   procedure Write_Warning
  1223.     ( Message        : in STRING );
  1224.  
  1225.   --| Purpose
  1226.   --| Write_Warning makes a warning message entry into the error log file.
  1227.   --|
  1228.   --| Exceptions (none)
  1229.   --| Notes (none)
  1230.  
  1231.   -- ..................................
  1232.   -- .                                .
  1233.   -- .  Close                         .  SPEC
  1234.   -- .                                .
  1235.   -- ..................................
  1236.   procedure Close;
  1237.  
  1238.   --| Purpose
  1239.   --| Close closes the error log file.
  1240.   --|
  1241.   --| Exceptions (none)
  1242.   --| Notes (none)
  1243.  
  1244. end Error_Log;
  1245. --::::::::::
  1246. --idx.a
  1247. --::::::::::
  1248. -- **********************************
  1249. -- *                                *
  1250. -- *  Index                         *  SPEC
  1251. -- *                                *
  1252. -- **********************************
  1253. package Index is
  1254.  
  1255. --| Purpose
  1256. --| Index is an abstract state machine which implements an index
  1257. --| of a document.
  1258. --|
  1259. --| Initialization Exceptions (none)
  1260. --| Notes (none)
  1261. --|
  1262. --| Modifications
  1263. --| 08/16/89  Rick Conn    Initial Version
  1264.  
  1265.   Index_File_Not_Open
  1266.     : exception;
  1267.  
  1268.   Create_Error
  1269.     : exception;
  1270.  
  1271.   -- ..................................
  1272.   -- .                                .
  1273.   -- .  Create                        .  SPEC
  1274.   -- .                                .
  1275.   -- ..................................
  1276.   procedure Create
  1277.     ( File_Name      : in STRING;
  1278.       Line_Width     : in NATURAL;
  1279.       Text_Line_Width : in NATURAL;
  1280.       Text_Line_Count : in NATURAL );
  1281.  
  1282.   --| Purpose
  1283.   --| Create creates the index file, setting the width of the lines.
  1284.   --|
  1285.   --| Exceptions
  1286.   --|   Create_Error    -- file cannot be created
  1287.   --| Notes (none)
  1288.  
  1289.   -- ..................................
  1290.   -- .                                .
  1291.   -- .  Add_Entry                     .  SPEC
  1292.   -- .                                .
  1293.   -- ..................................
  1294.   procedure Add_Entry
  1295.     ( Text           : in STRING;
  1296.       Page_Number    : in STRING );
  1297.  
  1298.   --| Purpose
  1299.   --| Add_Entry adds an entry to the index file.  If the text is too
  1300.   --| long, it is simply truncated with a warning message.
  1301.   --|
  1302.   --| Exceptions
  1303.   --|   Index_File_Not_Open  -- Create was not called yet
  1304.   --|
  1305.   --| Notes (none)
  1306.  
  1307.   -- ..................................
  1308.   -- .                                .
  1309.   -- .  Close                         .  SPEC
  1310.   -- .                                .
  1311.   -- ..................................
  1312.   procedure Close;
  1313.  
  1314.   --| Purpose
  1315.   --| Close closes an index file.
  1316.   --|
  1317.   --| Exceptions (none)
  1318.   --| Notes (none)
  1319.  
  1320. end Index;
  1321. --::::::::::
  1322. --var.a
  1323. --::::::::::
  1324. -- **********************************
  1325. -- *                                *
  1326. -- *  Variable                      *  SPEC
  1327. -- *                                *
  1328. -- **********************************
  1329. package Variable is
  1330.  
  1331. --| Purpose
  1332. --| Package Variable defines and provides access to the following
  1333. --| variables:
  1334. --|     1. Number Registers a-z
  1335. --|     2. Command Control Character
  1336. --|     3. Escape Character
  1337. --|     4. Flag Character
  1338. --|     5. Auto-Paragraphing Flag
  1339. --|     6. Bold line, Center line, and Underlined line counts
  1340. --|     7. Current File Name and Line Number
  1341. --|     8. User-Defined Text Variables
  1342. --|
  1343. --| Initialization Exceptions (none)
  1344. --| Notes (none)
  1345. --|
  1346. --| Modifications
  1347. --| 08/16/89  Rick Conn    Initial Version
  1348.  
  1349.   -- ..................................
  1350.   -- .                                .
  1351.   -- .  Set_Auto_Paragraph            .  SPEC
  1352.   -- .  Is_Auto_Paragraph             .
  1353.   -- .                                .
  1354.   -- ..................................
  1355.   Default_Auto_Paragraph
  1356.     : constant BOOLEAN
  1357.       := false;
  1358.  
  1359.   procedure Set_Auto_Paragraph
  1360.     ( Item           : in BOOLEAN );
  1361.   function Is_Auto_Paragraph
  1362.       return BOOLEAN;
  1363.  
  1364.   --| Purpose
  1365.   --| Set and return the value of the auto paragraphing flag.
  1366.   --|
  1367.   --| Exceptions (none)
  1368.   --| Notes (none)
  1369.  
  1370.   -- ..................................
  1371.   -- .                                .
  1372.   -- .  Set_Bold_Count                .  SPEC
  1373.   -- .  Bold_Count                    .
  1374.   -- .                                .
  1375.   -- ..................................
  1376.   procedure Set_Bold_Count
  1377.     ( Value          : in NATURAL );
  1378.   function Bold_Count
  1379.       return NATURAL;
  1380.  
  1381.   --| Purpose
  1382.   --| Set and return the value of the bold count.
  1383.   --|
  1384.   --| Exceptions (none)
  1385.   --| Notes (none)
  1386.  
  1387.   -- ..................................
  1388.   -- .                                .
  1389.   -- .  Set_Center_Count              .  SPEC
  1390.   -- .  Center_Count                  .
  1391.   -- .                                .
  1392.   -- ..................................
  1393.   procedure Set_Center_Count
  1394.     ( Value          : in NATURAL );
  1395.   function Center_Count
  1396.       return NATURAL;
  1397.  
  1398.   --| Purpose
  1399.   --| Set and return the value of the centering count.
  1400.   --|
  1401.   --| Exceptions (none)
  1402.   --| Notes (none)
  1403.  
  1404.   -- ..................................
  1405.   -- .                                .
  1406.   -- .  Set_Underline_Count           .  SPEC
  1407.   -- .  Underline_Count               .
  1408.   -- .                                .
  1409.   -- ..................................
  1410.   procedure Set_Underline_Count
  1411.     ( Value          : in NATURAL );
  1412.   function Underline_Count
  1413.       return NATURAL;
  1414.  
  1415.   --| Purpose
  1416.   --| Set and return the value of the underline count.
  1417.   --|
  1418.   --| Exceptions (none)
  1419.   --| Notes (none)
  1420.  
  1421.   -- ..................................
  1422.   -- .                                .
  1423.   -- .  Set_Cc                        .  SPEC
  1424.   -- .  Cc                            .
  1425.   -- .                                .
  1426.   -- ..................................
  1427.   Default_Cc
  1428.     : constant CHARACTER
  1429.       := '.';
  1430.  
  1431.   procedure Set_Cc
  1432.     ( Item           : in CHARACTER );
  1433.   function Cc
  1434.       return CHARACTER;
  1435.  
  1436.   --| Purpose
  1437.   --| Set and return the value of the command control character.
  1438.   --|
  1439.   --| Exceptions (none)
  1440.   --| Notes (none)
  1441.  
  1442.   -- ..................................
  1443.   -- .                                .
  1444.   -- .  Set_Ec                        .  SPEC
  1445.   -- .  Ec                            .
  1446.   -- .                                .
  1447.   -- ..................................
  1448.   Default_Ec
  1449.     : constant CHARACTER
  1450.       := '_';
  1451.  
  1452.   procedure Set_Ec
  1453.     ( Item           : in CHARACTER );
  1454.   function Ec
  1455.       return CHARACTER;
  1456.  
  1457.   --| Purpose
  1458.   --| Set and return the value of the escape character.
  1459.   --|
  1460.   --| Exceptions (none)
  1461.   --| Notes (none)
  1462.  
  1463.   -- ..................................
  1464.   -- .                                .
  1465.   -- .  Set_Fc                        .  SPEC
  1466.   -- .  Fc                            .
  1467.   -- .                                .
  1468.   -- ..................................
  1469.   Default_Fc
  1470.     : constant CHARACTER
  1471.       := '@';
  1472.  
  1473.   procedure Set_Fc
  1474.     ( Item           : in CHARACTER );
  1475.   function Fc
  1476.       return CHARACTER;
  1477.  
  1478.   --| Purpose
  1479.   --| Set and return the value of the flag character.
  1480.   --|
  1481.   --| Exceptions (none)
  1482.   --| Notes (none)
  1483.  
  1484.   -- ..................................
  1485.   -- .                                .
  1486.   -- .  Set_Nr                        .  SPEC
  1487.   -- .  Nr                            .
  1488.   -- .                                .
  1489.   -- ..................................
  1490.   subtype NREG is
  1491.     CHARACTER range 'a' .. 'z';
  1492.  
  1493.   procedure Set_Nr
  1494.     ( Item           : in NREG;
  1495.       Value          : in NATURAL );
  1496.   function Nr
  1497.     ( Item           : in NREG )
  1498.       return NATURAL;
  1499.   procedure Nr
  1500.     ( Item           : in NREG;
  1501.       Value          : out STRING;
  1502.       Last           : out NATURAL );
  1503.  
  1504.   --| Purpose
  1505.   --| Set and return the value of a number register.
  1506.   --|
  1507.   --| Exceptions (none)
  1508.   --| Notes (none)
  1509.  
  1510.   -- ..................................
  1511.   -- .                                .
  1512.   -- .  Set_Var                       .  SPEC
  1513.   -- .  Var                           .
  1514.   -- .                                .
  1515.   -- ..................................
  1516.   procedure Set_Var
  1517.     ( Name           : in STRING;
  1518.       Value          : in STRING );
  1519.   function Var
  1520.     ( Name           : in STRING )
  1521.       return STRING;
  1522.   procedure Var
  1523.     ( Name           : in STRING;
  1524.       Value          : out STRING;
  1525.       Last           : out NATURAL );
  1526.  
  1527.   --| Purpose
  1528.   --| Set and return the value of a user-defined text variable.
  1529.   --|
  1530.   --| Exceptions (none)
  1531.   --| Notes (none)
  1532.  
  1533.   -- ..................................
  1534.   -- .                                .
  1535.   -- .  Set_File_Name                 .  SPEC
  1536.   -- .  Get_File_Name                 .
  1537.   -- .  Set_Line_Number               .
  1538.   -- .  Increment_Line_Number         .
  1539.   -- .  Line_Number                   .
  1540.   -- .                                .
  1541.   -- ..................................
  1542.   procedure Set_File_Name
  1543.     ( Name           : in STRING );
  1544.   function Get_File_Name
  1545.       return STRING;
  1546.   procedure Set_Line_Number
  1547.     ( Value          : in NATURAL );
  1548.   procedure Increment_Line_Number;
  1549.   function Line_Number
  1550.       return NATURAL;
  1551.  
  1552.   --| Purpose
  1553.   --| Set and return the name of the current input file.  Also
  1554.   --| increment and return the line number (Set_File_Name zeroes
  1555.   --| the line number).
  1556.   --|
  1557.   --| Exceptions (none)
  1558.   --| Notes (none)
  1559.  
  1560. end Variable;
  1561. --::::::::::
  1562. --parse.a
  1563. --::::::::::
  1564. -- ..................................
  1565. -- .                                .
  1566. -- .  Parse                         .  SPEC & BODY
  1567. -- .                                .
  1568. -- ..................................
  1569. procedure Parse
  1570.   ( Item           : in STRING;
  1571.     Command_Verb   : out STRING;
  1572.     Command_Tail   : out STRING;
  1573.     Verb_Last      : out NATURAL;
  1574.     Tail_Last      : out NATURAL ) is
  1575.  
  1576. --| Purpose
  1577. --| Parse parses the input string, which does not begin with a dot, into
  1578. --| the strings Command_Verb and Command_Tail.  Verb_Last and Tail_Last
  1579. --| are set to the index of the last valid character.  Command_Verb
  1580. --| starts with the first character.  Command_Tail
  1581. --| starts with the first non-blank character after the verb.
  1582. --| The string Item is of the form:
  1583. --|    command_verb command_tail
  1584. --|
  1585. --| Exceptions (none)
  1586. --| Notes (none)
  1587. --|
  1588. --| Modifications
  1589. --| 08/16/89  Rick Conn    Initial Version
  1590.  
  1591.   First
  1592.     : NATURAL;
  1593.  
  1594.   Last
  1595.     : NATURAL;
  1596.  
  1597.   Temp
  1598.     : NATURAL;
  1599.  
  1600. begin -- Parse
  1601.  
  1602.   Verb_Last      := Command_Verb'First - 1;
  1603.   Tail_Last      := Command_Tail'First - 1;
  1604.   if Item'Length > 0 then
  1605.     First          := Item'First;
  1606.     Last           := Item'Last;
  1607.     for I in First .. Item'Last loop
  1608.       if Item(I) <= ' ' then
  1609.         Last           := I - 1;
  1610.         exit;
  1611.       end if;
  1612.     end loop;
  1613.     Temp           := Last - First + Command_Verb'First;
  1614.     Verb_Last      := Temp;
  1615.     Command_Verb(Command_Verb'First .. Temp) := Item(First .. Last);
  1616.  
  1617.     Last           := Last + 1;
  1618.     if Last <= Item'Last then
  1619.       First          := Item'Last + 1;
  1620.       for I in Last .. Item'Last loop
  1621.         if Item(I) > ' ' then
  1622.           First          := I;
  1623.           exit;
  1624.         end if;
  1625.       end loop;
  1626.       if First <= Item'Last then
  1627.         Temp           := Item'Last - First + Command_Tail'First;
  1628.         Tail_Last      := Temp;
  1629.         Command_Tail(Command_Tail'First .. Temp) := Item(First .. Item'Last);
  1630.       end if;
  1631.     end if;
  1632.  
  1633.   end if;
  1634.  
  1635. end Parse;
  1636. --::::::::::
  1637. --fof.a
  1638. --::::::::::
  1639. -- **********************************
  1640. -- *                                *
  1641. -- *  Formatted_Output_File         *  SPEC
  1642. -- *                                *
  1643. -- **********************************
  1644. package Formatted_Output_File is
  1645.  
  1646. --| Purpose
  1647. --| Text_Formatter manipulates objects of type STRING (text), placing
  1648. --| text into the output file as it is received.  Text_Formatter is
  1649. --| also used to define the format of the text (number of lines per page,
  1650. --| header, footer, etc.).
  1651. --|
  1652. --| Initialization Exceptions (none)
  1653. --| Notes (none)
  1654. --|
  1655. --| Modifications
  1656. --| 08/16/89   Rick Conn    Initial version
  1657.  
  1658.   type FILE is
  1659.     private;
  1660.  
  1661.   Maximum_Number_Of_Lines_On_Page
  1662.     : constant
  1663.       := 200;
  1664.  
  1665.   Maximum_Line_Length
  1666.     : constant
  1667.       := 200;
  1668.  
  1669.   Maximum_Number_Of_Header_Footer_Lines
  1670.     : constant
  1671.       := 8;
  1672.  
  1673.   Maximum_Number_Of_Pages
  1674.     : constant
  1675.       := 32000;
  1676.  
  1677.   pragma Format_Off;
  1678.  
  1679.   type PAGE_ATTRIBUTE is
  1680.     ( TOP_MARGIN,       -- Number of lines before first header
  1681.       BOTTOM_MARGIN,    -- Number of lines after last footer
  1682.       LEFT_MARGIN,      -- Column num of the last col before the 1st char
  1683.       RIGHT_MARGIN,     -- Column number of the last char of the line
  1684.       LEFT_INDENT,      -- Number of columns to indent from LEFT_MARGIN
  1685.       RIGHT_INDENT,     -- Number of columns to indent from RIGHT_MARGIN
  1686.       TOTAL_LINES,      -- Number of lines on a page
  1687.       HEADER_LINES,     -- Number of lines in the header
  1688.       FOOTER_LINES,     -- Number of lines in the footer
  1689.       LINE_SPACING,     -- Number of blank lines after each text line
  1690.       PAGE_OFFSET,      -- Number of columns to offset each line
  1691.       TEMP_INDENT       -- Number of columns to indent next line only
  1692.                         -- (this is an absolute value, not influenced
  1693.                         --  by the LEFT_MARGIN or LEFT_INDENT settings)
  1694.     );
  1695.  
  1696.   type LINE_ATTRIBUTE is
  1697.     ( BOLD,                     -- Make words come out bold (overstrike)
  1698.       CENTER,                   -- Center lines (Put_Line with No Fill)
  1699.       FILL,                     -- Successively place words into an output
  1700.                                 --  line until the next word will not fit
  1701.                                 --  between the left and right margins
  1702.                                 --  (with indents)
  1703.       FILL_STATE_BEFORE_CENTER, -- Save area for FILL
  1704.       JUSTIFY,                  -- Fill output line to RIGHT_MARGIN -
  1705.                                 --  RIGHT_INDENT with spaces between words
  1706.       PAGING,                   -- Break output on page boundaries,
  1707.                                 --  outputting footer, bottom margin,
  1708.                                 --  top margin, and header
  1709.       UNDERLINE,                -- Underline words
  1710.       UNDERLINE_PUNCT,          -- If ON, underline punctuation
  1711.       USE_FORM_FEED             -- Use form feeds to eject pages
  1712.     );
  1713.  
  1714.   type PAGE_ATTRIBUTE_LIST is
  1715.     array (PAGE_ATTRIBUTE)
  1716.       of NATURAL;
  1717.  
  1718.   type OFF_ON is
  1719.     ( OFF, ON );
  1720.  
  1721.   type LINE_ATTRIBUTE_LIST is
  1722.     array (LINE_ATTRIBUTE)
  1723.       of OFF_ON;
  1724.  
  1725.   Page_Attribute_Defaults
  1726.     : constant PAGE_ATTRIBUTE_LIST
  1727.       := (
  1728.         TOP_MARGIN     => 4,
  1729.         BOTTOM_MARGIN  => 4,
  1730.         LEFT_MARGIN    => 12,
  1731.         RIGHT_MARGIN   => 90,
  1732.         LEFT_INDENT    => 0,
  1733.         RIGHT_INDENT   => 0,
  1734.         TOTAL_LINES    => 66,
  1735.         HEADER_LINES   => 2,
  1736.         FOOTER_LINES   => 2,
  1737.         LINE_SPACING   => 0,
  1738.         PAGE_OFFSET    => 0,
  1739.         TEMP_INDENT    => 0 );
  1740.  
  1741.   Line_Attribute_Defaults
  1742.     : constant LINE_ATTRIBUTE_LIST
  1743.       := (
  1744.         BOLD           => OFF,
  1745.         CENTER         => OFF,
  1746.         FILL           => ON,
  1747.         FILL_STATE_BEFORE_CENTER => ON,
  1748.         JUSTIFY        => ON,
  1749.         PAGING         => ON,
  1750.         UNDERLINE      => OFF,
  1751.         UNDERLINE_PUNCT => OFF,
  1752.         USE_FORM_FEED  => ON );
  1753.  
  1754.   pragma Format_On;
  1755.  
  1756.   Page_Number_Id_Default
  1757.     : constant CHARACTER
  1758.       := '#';
  1759.  
  1760.   type LINE_NUMBER is
  1761.     new INTEGER range 0 .. Maximum_Number_Of_Lines_On_Page;
  1762.  
  1763.   type HEADER_FOOTER_LINE is                     -- H/F line numbers
  1764.     new INTEGER range 1 .. Maximum_Number_Of_Header_Footer_Lines;
  1765.  
  1766.   type PAGE_NUMBER is
  1767.     new INTEGER range 0 .. Maximum_Number_Of_Pages;
  1768.  
  1769.   type STATUS is                                 -- for Open
  1770.     ( OK, NOT_OK );
  1771.  
  1772.   type PAGE_SIDE is                              -- for margins and indents
  1773.     ( LEFT_SIDE, RIGHT_SIDE );
  1774.  
  1775.   type PAGE_KIND is                              -- for headers and footers
  1776.     ( EVEN_PAGES, ODD_PAGES, ALL_PAGES );
  1777.  
  1778.   type NUMERIC_FORMAT is                         -- for page numbers
  1779.     ( ARABIC, LOWER_ROMAN, UPPER_ROMAN );
  1780.  
  1781.   Range_Error
  1782.     : exception;
  1783.  
  1784.   File_Not_Open
  1785.     : exception;
  1786.  
  1787.   -- ..................................
  1788.   -- .                                .
  1789.   -- .  Open                          .  SPEC
  1790.   -- .                                .
  1791.   -- ..................................
  1792.  
  1793.   procedure Open
  1794.     ( Item           : in out FILE;
  1795.       File_Name      : in STRING;
  1796.       Result         : out STATUS );
  1797.  
  1798.   --| Purpose
  1799.   --| Open the formatted output file for subsequent processing.
  1800.   --|
  1801.   --| Exceptions (none)
  1802.   --| Notes (none)
  1803.  
  1804.   -- ..................................
  1805.   -- .                                .
  1806.   -- .  Close                         .  SPEC
  1807.   -- .                                .
  1808.   -- ..................................
  1809.   procedure Close
  1810.     ( Item           : in FILE );
  1811.  
  1812.   --| Purpose
  1813.   --| Close the formatted output file.
  1814.   --|
  1815.   --| Exceptions
  1816.   --| File_Not_Open
  1817.   --|
  1818.   --| Notes (none)
  1819.  
  1820.   -- ..................................
  1821.   -- .                                .
  1822.   -- .  Put_Invisible_Word            .  SPEC
  1823.   -- .                                .
  1824.   -- ..................................
  1825.   procedure Put_Invisible_Word
  1826.     ( Item           : in FILE;
  1827.       What           : in STRING );
  1828.  
  1829.   --| Purpose
  1830.   --| Add a word to the current line and do not increment the
  1831.   --| character count.
  1832.   --|
  1833.   --| Exceptions
  1834.   --| File_Not_Open
  1835.   --|
  1836.   --| Notes (none)
  1837.  
  1838.  
  1839.   -- ..................................
  1840.   -- .                                .
  1841.   -- .  Put_Word                      .  SPEC
  1842.   -- .                                .
  1843.   -- ..................................
  1844.   procedure Put_Word
  1845.     ( Item           : in FILE;
  1846.       What           : in STRING );
  1847.  
  1848.   --| Purpose
  1849.   --| Add a word to the current line.
  1850.   --|
  1851.   --| Exceptions
  1852.   --| File_Not_Open
  1853.   --|
  1854.   --| Notes (none)
  1855.  
  1856.   -- ..................................
  1857.   -- .                                .
  1858.   -- .  Put_Line                      .  SPEC
  1859.   -- .                                .
  1860.   -- ..................................
  1861.   procedure Put_Line
  1862.     ( Item           : in FILE;
  1863.       What           : in STRING );
  1864.  
  1865.   --| Purpose
  1866.   --| Add a line to the current page.  If line break, insert blank
  1867.   --| lines as per LINE_SPACING.
  1868.   --|
  1869.   --| Exceptions
  1870.   --| File_Not_Open
  1871.   --|
  1872.   --| Notes (none)
  1873.  
  1874.   -- ..................................
  1875.   -- .                                .
  1876.   -- .  Break_Line                    .  SPEC
  1877.   -- .                                .
  1878.   -- ..................................
  1879.   procedure Break_Line
  1880.     ( Item           : in FILE );
  1881.  
  1882.   --| Purpose
  1883.   --| Break the current line (if it contains any words, output them).
  1884.   --| Insert blank lines as per the LINE_SPACING setting.
  1885.   --|
  1886.   --| Exceptions
  1887.   --| File_Not_Open
  1888.   --|
  1889.   --| Notes (none)
  1890.  
  1891.   -- ..................................
  1892.   -- .                                .
  1893.   -- .  Current_Line                  .  SPEC
  1894.   -- .                                .
  1895.   -- ..................................
  1896.   function Current_Line
  1897.     ( Item           : in FILE )
  1898.       return LINE_NUMBER;
  1899.  
  1900.   --| Purpose
  1901.   --| Return the number of the current line.
  1902.   --|
  1903.   --| Exceptions
  1904.   --| File_Not_Open
  1905.   --|
  1906.   --| Notes (none)
  1907.  
  1908.   -- ..................................
  1909.   -- .                                .
  1910.   -- .  Skip                          .  SPEC
  1911.   -- .                                .
  1912.   -- ..................................
  1913.   procedure Skip
  1914.     ( Item           : in FILE;
  1915.       Number_Of_Lines : in LINE_NUMBER := 1 );
  1916.  
  1917.   --| Purpose
  1918.   --| Skip Number_Of_Lines in the output after first issuing a Break_Line.
  1919.   --| LINE_SPACING influences the actual number of lines skipped.
  1920.   --|
  1921.   --| Exceptions
  1922.   --| File_Not_Open
  1923.   --|
  1924.   --| Notes (none)
  1925.  
  1926.   -- ..................................
  1927.   -- .                                .
  1928.   -- .  Break_Page                    .  SPEC
  1929.   -- .  Break_Page                    .
  1930.   -- .                                .
  1931.   -- ..................................
  1932.   procedure Break_Page
  1933.     ( Item           : in FILE );
  1934.  
  1935.   --| Purpose
  1936.   --| If there is anything on the current page, output it and advance
  1937.   --| to the next page.
  1938.   --|
  1939.   --| Exceptions
  1940.   --| File_Not_Open
  1941.   --|
  1942.   --| Notes (none)
  1943.  
  1944.   procedure Break_Page
  1945.     ( Item           : in FILE;
  1946.       New_Page_Num   : in PAGE_NUMBER );
  1947.  
  1948.   --| Purpose
  1949.   --| If there is anything on the current page, output it and advance
  1950.   --| to the next page.  Set the number of the next page to New_Page_Num.
  1951.   --|
  1952.   --| Exceptions
  1953.   --| File_Not_Open
  1954.   --|
  1955.   --| Notes (none)
  1956.  
  1957.   -- ..................................
  1958.   -- .                                .
  1959.   -- .  Current_Page                  .  SPEC
  1960.   -- .                                .
  1961.   -- ..................................
  1962.   function Current_Page
  1963.     ( Item           : in FILE )
  1964.       return PAGE_NUMBER;
  1965.  
  1966.   --| Purpose
  1967.   --| Return the number of the current page.
  1968.   --|
  1969.   --| Exceptions
  1970.   --| File_Not_Open
  1971.   --|
  1972.   --| Notes (none)
  1973.  
  1974.   -- ..................................
  1975.   -- .                                .
  1976.   -- .  Current_Page                  .  SPEC
  1977.   -- .                                .
  1978.   -- ..................................
  1979.   function Current_Page
  1980.     ( Item           : in FILE )
  1981.       return STRING;
  1982.  
  1983.   --| Purpose
  1984.   --| Return the number of the current page as a string.
  1985.   --|
  1986.   --| Exceptions
  1987.   --| File_Not_Open
  1988.   --|
  1989.   --| Notes (none)
  1990.  
  1991.   -- ..................................
  1992.   -- .                                .
  1993.   -- .  Set_Page_Number_Format        .  SPEC
  1994.   -- .                                .
  1995.   -- ..................................
  1996.   procedure Set_Page_Number_Format
  1997.     ( Item           : in FILE;
  1998.       To             : in NUMERIC_FORMAT;
  1999.       Format_String  : in STRING );
  2000.  
  2001.   --| Purpose
  2002.   --| Set the format of the page number.  If the Format_String is not
  2003.   --| null, the page numbers in the headers and footers will appear as
  2004.   --| indicated (with the literal number substituted for # characters).
  2005.   --|
  2006.   --| Exceptions
  2007.   --| File_Not_Open
  2008.   --|
  2009.   --| Notes (none)
  2010.  
  2011.   -- ..................................
  2012.   -- .                                .
  2013.   -- .  Set_Page_Attribute            .  SPEC
  2014.   -- .                                .
  2015.   -- ..................................
  2016.   procedure Set_Page_Attribute
  2017.     ( Item           : in FILE;
  2018.       What           : in PAGE_ATTRIBUTE;
  2019.       To             : in NATURAL );
  2020.  
  2021.   --| Purpose
  2022.   --| Set a specified page attribute.
  2023.   --|
  2024.   --| Exceptions
  2025.   --| Range_Error    raised if To is outside the range for What
  2026.   --| File_Not_Open
  2027.   --|
  2028.   --| Notes (none)
  2029.  
  2030.   -- ..................................
  2031.   -- .                                .
  2032.   -- .  Set_Line_Attribute            .  SPEC
  2033.   -- .                                .
  2034.   -- ..................................
  2035.   procedure Set_Line_Attribute
  2036.     ( Item           : in FILE;
  2037.       What           : in LINE_ATTRIBUTE;
  2038.       To             : in OFF_ON );
  2039.  
  2040.   --| Purpose
  2041.   --| Turn off or on the indicated attribute for the current and
  2042.   --| following lines.
  2043.   --|
  2044.   --| Exceptions
  2045.   --| File_Not_Open
  2046.   --|
  2047.   --| Notes (none)
  2048.  
  2049.   -- ..................................
  2050.   -- .                                .
  2051.   -- .  Get_Page_Attribute            .  SPEC
  2052.   -- .                                .
  2053.   -- ..................................
  2054.   function Get_Page_Attribute
  2055.     ( Item           : in FILE;
  2056.       What           : in PAGE_ATTRIBUTE )
  2057.       return NATURAL;
  2058.  
  2059.   --| Purpose
  2060.   --| Get a specified page attribute.
  2061.   --|
  2062.   --| Exceptions
  2063.   --| File_Not_Open
  2064.   --|
  2065.   --| Notes (none)
  2066.  
  2067.   -- ..................................
  2068.   -- .                                .
  2069.   -- .  Get_Line_Attribute            .  SPEC
  2070.   -- .                                .
  2071.   -- ..................................
  2072.   function Get_Line_Attribute
  2073.     ( Item           : in FILE;
  2074.       What           : in LINE_ATTRIBUTE )
  2075.       return OFF_ON;
  2076.  
  2077.   --| Purpose
  2078.   --| Get the indicated attribute for the current and
  2079.   --| following lines.
  2080.   --|
  2081.   --| Exceptions
  2082.   --| File_Not_Open
  2083.   --|
  2084.   --| Notes (none)
  2085.  
  2086.   -- ..................................
  2087.   -- .                                .
  2088.   -- .  Test_Page                     .  SPEC
  2089.   -- .                                .
  2090.   -- ..................................
  2091.   function Test_Page
  2092.     ( Item           : in FILE;
  2093.       Number_Of_Lines : in LINE_NUMBER )
  2094.       return BOOLEAN;
  2095.  
  2096.   --| Purpose
  2097.   --| Return TRUE if Number_Of_Lines is remaining on the current page.
  2098.   --|
  2099.   --| Exceptions
  2100.   --| File_Not_Open
  2101.   --|
  2102.   --| Notes (none)
  2103.  
  2104.   -- ..................................
  2105.   -- .                                .
  2106.   -- .  Set_Footer_Line               .  SPEC
  2107.   -- .                                .
  2108.   -- ..................................
  2109.   procedure Set_Footer_Line
  2110.     ( Item           : in FILE;
  2111.       Class          : in PAGE_KIND;
  2112.       Number         : in HEADER_FOOTER_LINE;
  2113.       Left_Text      : in STRING;
  2114.       Center_Text    : in STRING;
  2115.       Right_Text     : in STRING );
  2116.  
  2117.   --| Purpose
  2118.   --| Store a footer line for EVEN, ODD, or ALL pages.
  2119.   --| The footer line is dynamically adjusted, based on the left and right
  2120.   --| margin settings.  The strings Left, Center, and Right are left-
  2121.   --| justified, centered, and right-justified in the indicated footer
  2122.   --| line, respectively.
  2123.   --|
  2124.   --| Exceptions
  2125.   --| File_Not_Open
  2126.   --|
  2127.   --| Notes (none)
  2128.  
  2129.   -- ..................................
  2130.   -- .                                .
  2131.   -- .  Set_Header_Line               .  SPEC
  2132.   -- .                                .
  2133.   -- ..................................
  2134.   procedure Set_Header_Line
  2135.     ( Item           : in FILE;
  2136.       Class          : in PAGE_KIND;
  2137.       Number         : in HEADER_FOOTER_LINE;
  2138.       Left_Text      : in STRING;
  2139.       Center_Text    : in STRING;
  2140.       Right_Text     : in STRING );
  2141.  
  2142.   --| Purpose
  2143.   --| Store a header line for EVEN, ODD, or ALL pages.
  2144.   --| The header line is dynamically adjusted, based on the left and right
  2145.   --| margin settings.  The strings Left, Center, and Right are left-
  2146.   --| justified, centered, and right-justified in the indicated header
  2147.   --| line, respectively.
  2148.   --|
  2149.   --| Exceptions
  2150.   --| File_Not_Open
  2151.   --|
  2152.   --| Notes (none)
  2153.  
  2154.   -- ..................................
  2155.   -- .                                .
  2156.   -- .  Set_Page_Number_Id            .  SPEC
  2157.   -- .                                .
  2158.   -- ..................................
  2159.   procedure Set_Page_Number_Id
  2160.     ( Item           : in FILE;
  2161.       To             : in CHARACTER );
  2162.  
  2163.   --| Purpose
  2164.   --| Set the character used to represent the page number in the
  2165.   --| header and footer lines of the output file.
  2166.   --|
  2167.   --| Exceptions
  2168.   --| File_Not_Open
  2169.   --|
  2170.   --| Notes (none)
  2171.  
  2172.   -- ..................................
  2173.   -- .                                .
  2174.   -- .  Set_Page_Number_Format        .  SPEC
  2175.   -- .                                .
  2176.   -- ..................................
  2177.   procedure Set_Page_Number_Format
  2178.     ( Item           : in FILE;
  2179.       To             : in NUMERIC_FORMAT );
  2180.  
  2181.   --| Purpose
  2182.   --| Set the format used to represent the page number in the
  2183.   --| header and footer lines of the output file.
  2184.   --|
  2185.   --| Exceptions
  2186.   --| File_Not_Open
  2187.   --|
  2188.   --| Notes (none)
  2189.  
  2190.   -- ..................................
  2191.   -- .                                .
  2192.   -- .  Page_Number_Format            .  SPEC
  2193.   -- .                                .
  2194.   -- ..................................
  2195.   function Page_Number_Format
  2196.     ( Item           : in FILE )
  2197.     return NUMERIC_FORMAT;
  2198.  
  2199.   --| Purpose
  2200.   --| Get the format used to represent the page number in the
  2201.   --| header and footer lines of the output file.
  2202.   --|
  2203.   --| Exceptions
  2204.   --| File_Not_Open
  2205.   --|
  2206.   --| Notes (none)
  2207.  
  2208. private -- Formatted_Output_File
  2209.  
  2210.   type FILE_OBJECT;
  2211.   type FILE is
  2212.     access FILE_OBJECT;
  2213.  
  2214. end Formatted_Output_File;
  2215. --::::::::::
  2216. --cnt.a
  2217. --::::::::::
  2218. -- **********************************
  2219. -- *                                *
  2220. -- *  Contents                      *  SPEC
  2221. -- *                                *
  2222. -- **********************************
  2223. with Formatted_Output_File;
  2224. package Contents is
  2225.  
  2226. --| Purpose
  2227. --| Contents_Page adds lines to the table of contents and
  2228. --| prints the table of contents.  Once the table of contents
  2229. --| has been printed, no more lines may be added to it.
  2230. --|
  2231. --| Initialization Exceptions (none)
  2232. --| Notes (none)
  2233. --|
  2234. --| Modifications
  2235. --| 08/16/89  Rick Conn    Initial Version
  2236.  
  2237.   subtype TABLE_NUMBER is
  2238.     NATURAL range 0 .. 5;
  2239.  
  2240.   -- ..................................
  2241.   -- .                                .
  2242.   -- .  Select_Table                  .  SPEC
  2243.   -- .                                .
  2244.   -- ..................................
  2245.   procedure Select_Table
  2246.     ( Which_Table    : in TABLE_NUMBER );
  2247.  
  2248.   --| Purpose
  2249.   --| Select_Table selects one of the tables of contents.
  2250.   --| The Add_Line and Print routines below operate on the last table
  2251.   --| selected.  Table 0 is selected by default.
  2252.   --|
  2253.   --| Exceptions (none)
  2254.   --| Notes (none)
  2255.  
  2256.   -- ..................................
  2257.   -- .                                .
  2258.   -- .  Add_Line                      .  SPEC
  2259.   -- .                                .
  2260.   -- ..................................
  2261.   procedure Add_Line
  2262.     ( Level          : in NATURAL;
  2263.       Line           : in STRING;
  2264.       Page_Number    : in STRING );
  2265.  
  2266.   --| Purpose
  2267.   --| Add_Line adds a line, at the indicated indentation level, to
  2268.   --| the table of contents.
  2269.   --|
  2270.   --| Exceptions (none)
  2271.   --| Notes (none)
  2272.  
  2273.   -- ..................................
  2274.   -- .                                .
  2275.   -- .  Print                         .  SPEC
  2276.   -- .                                .
  2277.   -- ..................................
  2278.   procedure Print
  2279.     ( Target         : in Formatted_Output_File.File;
  2280.       Spaces_Per_Level : in NATURAL );
  2281.  
  2282.   --| Purpose
  2283.   --| Print prints the table of contents, indenting every Spaces_Per_Level
  2284.   --| at each indentation level.
  2285.   --|
  2286.   --| Exceptions (none)
  2287.   --| Notes (none)
  2288.  
  2289. end Contents;
  2290. --::::::::::
  2291. --env.a
  2292. --::::::::::
  2293. -- **********************************
  2294. -- *                                *
  2295. -- *  Environment                   *  SPEC
  2296. -- *                                *
  2297. -- **********************************
  2298. with Formatted_Output_File;
  2299. package Environment is
  2300.  
  2301. --| Purpose
  2302. --| Environment provides a mechanism for saving the current environment
  2303. --| and then later restoring it.  The environment consists of the
  2304. --| page attribute list and the line attribute list of the indicated
  2305. --| Formatted_Output_File object.  It also consists of the three formatter
  2306. --| key characters (Cc, Ec, and Fc).
  2307. --|
  2308. --| Initialization Exceptions (none)
  2309. --| Notes (none)
  2310. --|
  2311. --| Modifications
  2312. --| 08/16/89  Rick Conn    Initial Version
  2313. --| 02/26/90  Rick Conn    Add Set_Underlining to Pop/Push
  2314.  
  2315.   -- ..................................
  2316.   -- .                                .
  2317.   -- .  Pop                           .  SPEC
  2318.   -- .                                .
  2319.   -- ..................................
  2320.   procedure Pop
  2321.     ( Item            : in Formatted_Output_File.File;
  2322.       Set_Bolding     : in out BOOLEAN;
  2323.       Set_Underlining : in out BOOLEAN );
  2324.  
  2325.   --| Purpose
  2326.   --| Pop pops the attributes off the stack.  If the stack is empty,
  2327.   --| Pop writes an error message.
  2328.   --|
  2329.   --| Exceptions (none)
  2330.   --| Notes (none)
  2331.  
  2332.   -- ..................................
  2333.   -- .                                .
  2334.   -- .  Push                          .  SPEC
  2335.   -- .                                .
  2336.   -- ..................................
  2337.   procedure Push
  2338.     ( Item            : in Formatted_Output_File.File;
  2339.       Set_Bolding     : in BOOLEAN;
  2340.       Set_Underlining : in BOOLEAN );
  2341.  
  2342.   --| Purpose
  2343.   --| Push pushes the attributes onto the stack.  If the stack is full,
  2344.   --| Push writes an error message.
  2345.   --|
  2346.   --| Exceptions (none)
  2347.   --| Notes (none)
  2348.  
  2349. end Environment;
  2350. --::::::::::
  2351. --mac.a
  2352. --::::::::::
  2353. -- **********************************
  2354. -- *                                *
  2355. -- *  Macro                         *  SPEC
  2356. -- *                                *
  2357. -- **********************************
  2358. package Macro is
  2359.  
  2360. --| Purpose
  2361. --| Macro is used to manipulate an abstract state machine
  2362. --| which contains a group of macro definitions.  It provides routines
  2363. --| for building new macro definitions and extracting the lines from
  2364. --| a macro definition.
  2365. --|
  2366. --| Initialization Exceptions (none)
  2367. --| Notes (none)
  2368. --|
  2369. --| Modifications
  2370. --| 08/16/89  Rick Conn    Initial Version
  2371.  
  2372.   type MACRO_ID is
  2373.     private;
  2374.  
  2375.   type MACRO_STATUS is
  2376.     ( NOT_OK, OK );
  2377.  
  2378.   Macro_Not_In_Add_Mode
  2379.     : exception;
  2380.  
  2381.   Macro_Not_Open
  2382.     : exception;
  2383.  
  2384.   -- ..................................
  2385.   -- .                                .
  2386.   -- .  Create                        .  SPEC
  2387.   -- .                                .
  2388.   -- ..................................
  2389.  
  2390.   procedure Create
  2391.     ( Macro_Name     : in STRING;
  2392.       Id             : in out MACRO_ID;
  2393.       Status         : out MACRO_STATUS );
  2394.  
  2395.   --| Purpose
  2396.   --| Define and initialize a new macro.  Return a Status of OK if the
  2397.   --| program may proceed with calls to Write.  The programmer should
  2398.   --| create a new macro by taking the following steps:
  2399.   --|    1. Call Create to create the macro
  2400.   --|    2. If status is OK, then
  2401.   --|    2.1. Call Write as necessary to write lines into the macro
  2402.   --|    2.2. Call Close to close the macro
  2403.   --|
  2404.   --| Exceptions (none)
  2405.   --| Notes (none)
  2406.  
  2407.   -- ..................................
  2408.   -- .                                .
  2409.   -- .  Write                         .  SPEC
  2410.   -- .                                .
  2411.   -- ..................................
  2412.   procedure Write
  2413.     ( Id             : in out MACRO_ID;
  2414.       Line           : in STRING );
  2415.  
  2416.   --| Purpose
  2417.   --| Write adds the indicated line to the macro opened with Create.
  2418.   --|
  2419.   --| Exceptions
  2420.   --| Macro_Not_In_Add_Mode    Macro was not opened with Create
  2421.   --|
  2422.   --| Notes (none)
  2423.  
  2424.   -- ..................................
  2425.   -- .                                .
  2426.   -- .  Open                          .  SPEC
  2427.   -- .                                .
  2428.   -- ..................................
  2429.   procedure Open
  2430.     ( Macro_Name     : in STRING;
  2431.       Id             : out MACRO_ID;
  2432.       Status         : out MACRO_STATUS );
  2433.  
  2434.   --| Purpose
  2435.   --| Open the indicated macro for subsequent reading.  The programmer should
  2436.   --| take the following steps to read a macro:
  2437.   --|     1. Open the macro
  2438.   --|     2. If status is OK, then:
  2439.   --|     2.1. If not Is_Empty, then
  2440.   --|     2.1.1.  Read next line from macro
  2441.   --|     2.1.2.  Loop back to 2.1
  2442.   --|     2.2. Close the macro
  2443.   --|
  2444.   --| Exceptions (none)
  2445.   --| Notes (none)
  2446.  
  2447.   -- ..................................
  2448.   -- .                                .
  2449.   -- .  Is_Empty                      .  SPEC
  2450.   -- .                                .
  2451.   -- ..................................
  2452.   function Is_Empty
  2453.     ( Id             : in MACRO_ID )
  2454.       return BOOLEAN;
  2455.  
  2456.   --| Purpose
  2457.   --| Is_Empty is the basis for a loop iterator, indicating if any more
  2458.   --| lines are available from the indicated macro.
  2459.   --|
  2460.   --| Exceptions
  2461.   --| Macro_Not_Open    The macro has not been opened
  2462.   --|
  2463.   --| Notes (none)
  2464.  
  2465.   -- ..................................
  2466.   -- .                                .
  2467.   -- .  Read                          .  SPEC
  2468.   -- .                                .
  2469.   -- ..................................
  2470.   procedure Read
  2471.     ( Id             : in out MACRO_ID;
  2472.       Item           : out STRING;
  2473.       Last           : out NATURAL );
  2474.  
  2475.   --| Purpose
  2476.   --| Read reads the next line from the indicated macro.
  2477.   --|
  2478.   --| Exceptions
  2479.   --| Macro_Not_Open    The macro has not been opened
  2480.   --|
  2481.   --| Notes (none)
  2482.  
  2483.   -- ..................................
  2484.   -- .                                .
  2485.   -- .  Close                         .  SPEC
  2486.   -- .                                .
  2487.   -- ..................................
  2488.   procedure Close
  2489.     ( Id             : in out MACRO_ID );
  2490.  
  2491.   --| Purpose
  2492.   --| Close the indicated macro from reading or writing.  If the macro was
  2493.   --| opened by a call to Open, then access to it is simply closed.  If the
  2494.   --| macro was opened by a call to Create, then no more lines may be added
  2495.   --| to it.
  2496.   --|
  2497.   --| Exceptions
  2498.   --| Macro_Not_Open    The macro has not been opened
  2499.   --|
  2500.   --| Notes
  2501.   --| Close performs differently if the macro was opened by Create or Open.
  2502.  
  2503.   -- ..................................
  2504.   -- .                                .
  2505.   -- .  Locate                        .  SPEC
  2506.   -- .                                .
  2507.   -- ..................................
  2508.   function Locate
  2509.     ( Macro_Name     : in STRING )
  2510.       return MACRO_STATUS;
  2511.  
  2512.   --| Purpose
  2513.   --| Locate determines if the indicated macro is already defined (created
  2514.   --| by calls to Create, Write, and Close).  If so, Locate returns OK, else
  2515.   --| Locate returns NOT_OK.
  2516.   --|
  2517.   --| Exceptions (none)
  2518.   --| Notes (none)
  2519.  
  2520.   -- ..................................
  2521.   -- .                                .
  2522.   -- .  Define_Parameters             .  SPEC
  2523.   -- .                                .
  2524.   -- ..................................
  2525.   procedure Define_Parameters
  2526.     ( Macro_Name     : in STRING;
  2527.       Parameters     : in STRING );
  2528.  
  2529.   --| Purpose
  2530.   --| Define_Parameters creates the variables @0 to @9 for reference by
  2531.   --| commands within a macro.
  2532.   --|
  2533.   --| Exceptions (none)
  2534.   --| Notes (none)
  2535.  
  2536. private -- Macro
  2537.  
  2538.   type MACRO_DEFINITION;                         -- deferred to body
  2539.   type MACRO_ID is
  2540.     access MACRO_DEFINITION;
  2541.  
  2542. end Macro;
  2543. --::::::::::
  2544. --cmd.a
  2545. --::::::::::
  2546. -- **********************************
  2547. -- *                                *
  2548. -- *  Command                       *  SPEC
  2549. -- *                                *
  2550. -- **********************************
  2551. with Command_Symbols;
  2552. with Formatted_Output_File;
  2553. with Input_File;
  2554. package Command is
  2555.  
  2556. --| Purpose
  2557. --| Command provides all the command identification and processing
  2558. --| functions for the word processor.
  2559. --|
  2560. --| Initialization Exceptions (none)
  2561. --| Notes (none)
  2562. --|
  2563. --| Modifications
  2564. --| 08/16/89  Rick Conn    Initial Version
  2565.  
  2566.   -- ..................................
  2567.   -- .                                .
  2568.   -- .  Identify                      .  SPEC
  2569.   -- .                                .
  2570.   -- ..................................
  2571.   function Identify
  2572.     ( Item           : in STRING )
  2573.       return Command_Symbols.Command_Id;
  2574.  
  2575.   --| Purpose
  2576.   --| Identify_Command determines the COMMAND_ID of the indicated
  2577.   --| command name.  Item should not contain the leading dot
  2578.   --| or any trailing or embedded spaces or characters.  If the
  2579.   --| Item does not contain any known command, a COMMAND_ID of UNKNOWN
  2580.   --| is returned.
  2581.   --|
  2582.   --| Exceptions (none)
  2583.   --| Notes (none)
  2584.  
  2585.   -- ..................................
  2586.   -- .                                .
  2587.   -- .  Process                       .  SPEC
  2588.   -- .                                .
  2589.   -- ..................................
  2590.   procedure Process
  2591.     ( Id             : in Command_Symbols.Command_Id;
  2592.       Line_Tail      : in STRING;
  2593.       Target         : in out Formatted_Output_File.File;
  2594.       Input_File_Id  : in out Input_File.File_Type );
  2595.  
  2596.   --| Purpose
  2597.   --| Process_Command processes the indicated command on the indicated Target
  2598.   --| file.  Line_Tail contains the text following the command verb from the
  2599.   --| dot command line (i.e., dot command is ".command_verb text").
  2600.   --|
  2601.   --| Exceptions (none)
  2602.   --| Notes (none)
  2603.  
  2604.   -- ..................................
  2605.   -- .                                .
  2606.   -- .  Disable_Bolding               .  SPEC
  2607.   -- .                                .
  2608.   -- ..................................
  2609.   procedure Disable_Bolding;
  2610.  
  2611.   --| Purpose
  2612.   --| Disable_Bolding allows the caller to initially disable the bold
  2613.   --| face feature of the system (useful if the document is a draft).
  2614.   --|
  2615.   --| Exceptions (none)
  2616.   --| Notes (none)
  2617.  
  2618.   -- ..................................
  2619.   -- .                                .
  2620.   -- .  Disable_Underlining           .  SPEC
  2621.   -- .                                .
  2622.   -- ..................................
  2623.   procedure Disable_Underlining;
  2624.  
  2625.   --| Purpose
  2626.   --| Disable_Underlining allows the caller to initially disable the
  2627.   --| underlining feature of the system (useful if the document is a
  2628.   --| draft).
  2629.   --|
  2630.   --| Exceptions (none)
  2631.   --| Notes (none)
  2632.  
  2633. end Command;
  2634. --::::::::::
  2635. --wp.a
  2636. --::::::::::
  2637. -- **********************************
  2638. -- *                                *
  2639. -- *  Word_Processor                *  SPEC
  2640. -- *                                *
  2641. -- **********************************
  2642. package Word_Processor is
  2643.  
  2644. --| Purpose
  2645. --| Word_Processor is an abstract state machine which reads one or
  2646. --| more input text files, processing text and commands from them,
  2647. --| placing the output into a common output file.  The output file
  2648. --| must be opened before any of the input files are processed.
  2649. --|
  2650. --| Initialization Exceptions (none)
  2651. --| Notes (none)
  2652. --|
  2653. --| Modifications
  2654. --| 08/16/89  Rick Conn    Initial Version
  2655. --| 02/26/90  Rick Conn    Add Disable Underlining Flag
  2656.  
  2657.   type OPERATION_STATUS is
  2658.     ( NOT_OK, OK );
  2659.  
  2660.   Output_File_Not_Open
  2661.     : exception;
  2662.  
  2663.   -- ..................................
  2664.   -- .                                .
  2665.   -- .  Open_Output_File              .  SPEC
  2666.   -- .                                .
  2667.   -- ..................................
  2668.  
  2669.   function Open_Output_File
  2670.     ( File_Name           : in STRING;
  2671.       Page_Offset         : in NATURAL;
  2672.       Disable_Bolding     : in BOOLEAN;
  2673.       Disable_Underlining : in BOOLEAN )
  2674.       return OPERATION_STATUS;
  2675.  
  2676.   --| Purpose
  2677.   --| Open_Output_File opens the output file.  If it cannot be opened,
  2678.   --| the status of NOT_OK is returned.
  2679.   --|
  2680.   --| Exceptions (none)
  2681.   --| Notes (none)
  2682.  
  2683.   -- ..................................
  2684.   -- .                                .
  2685.   -- .  Process_Source_File           .  SPEC
  2686.   -- .                                .
  2687.   -- ..................................
  2688.   function Process_Source_File
  2689.     ( File_Name      : in STRING )
  2690.       return OPERATION_STATUS;
  2691.  
  2692.   --| Purpose
  2693.   --| Process_Source_File processes the lines from the indicated source file.
  2694.   --| It may be called recursively.
  2695.   --|
  2696.   --| Exceptions
  2697.   --| Output_File_Not_Open    The destination output file is not opened
  2698.   --|
  2699.   --| Notes (none)
  2700.  
  2701.   -- ..................................
  2702.   -- .                                .
  2703.   -- .  Close_Output_File             .  SPEC
  2704.   -- .                                .
  2705.   -- ..................................
  2706.   procedure Close_Output_File;
  2707.  
  2708.   --| Purpose
  2709.   --| Close_Output_File closes the output file.
  2710.   --|
  2711.   --| Exceptions (none)
  2712.   --| Notes (none)
  2713.  
  2714. end Word_Processor;
  2715.